#include "qmachineconfig.h"

#include "qdatabaseloader.h"

#include <QApplication>

QMachineConfig::QMachineConfig():
    m_funcode_config(new QDataBaseLoader(0)),
    m_runtime_config(new QDataBaseLoader(0))
{
}

QMachineConfig::~QMachineConfig()
{
    delete m_funcode_config;
    delete m_runtime_config;
}

bool QMachineConfig::load(const QString &type, const QString &version)
{
    QString path=qApp->applicationDirPath()+"/database/"+type+"_"+version;

    bool ret;

    ret=m_funcode_config->load(path+"/CN_"+type+"_FUNCODE_"+version+".xml");

    if(!ret)
    {
        return false;
    }

    ret=m_runtime_config->load(path+"/CN_"+type+"_RUNTIME_"+version+".xml");
    if(!ret)
    {
        return false;
    }
    return true;
}

QDataBaseLoader* QMachineConfig::get_funcode_config()
{
    return m_funcode_config;
}

QDataBaseLoader* QMachineConfig::get_runtime_config()
{
    return m_runtime_config;
}
